package com.yimiyisu.contract_cust.controller;

import com.zen.ZenController;
import com.zen.ZenData;
import com.zen.ZenEngine;
import com.zen.ZenResult;
import com.zen.annotation.AccessRole;
import com.zen.annotation.Inject;
import com.zen.enums.ZenRole;

import java.util.List;

@AccessRole(ZenRole.ADMIN)
public class Attachment extends ZenController {
    @Inject
    private ZenEngine zenEngine;

    /**
     * 添加附件
     */
    public ZenResult addAttachment(ZenData data) {
        List<String> manager = data.getAsList("manager", String.class);
        ZenResult result = zenEngine.execute("get/contract", ZenData.create("id", data.get("contractId")));
        if(result.get("head") != null){
            manager.add(result.get("head"));
        }
        manager.add(data.getUid());
        data.put("manager", manager);
        zenEngine.execute("put/attachment", data);
        return ZenResult.success();
    }
}
